<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    {include file="/layout/scriptload"}
    <title>公众号列表</title>
</head>
<body>
<div class="box">
    <!-- /.box-header -->
    <section class="content">
    <div class="box-body">
        <form role="form">
            <div class="form-group col-md-7" >
                <label>账号昵称</label>
                <input type="text" id="name" class="form-control" value="{$data.name}" placeholder="输入账号昵称...">
            </div>
            <div class="form-group col-md-7" >
                <label>账号密码</label>
                <input type="text" id="password" class="form-control" value="{$data.password}" placeholder="输入账号密码...">
            </div>
            <div class="form-group col-md-7">
                <label>所属一级分类</label>
                <select id="category" class="form-control">
                    <option value="">请选择...</option>
                    {volist name="category" id='vo'}
                        <option {if condition="$vo.id eq $data.category"}selected="selected"{/if} value="{$vo.id}">{$vo.categoryname}</option>
                    {/volist}
                </select>
            </div>
            <div class="form-group col-md-7">
                <label>所属二级分类</label>
                <select id="category2" class="form-control">
                    <option value="">请选择...</option>
                    {volist name="category2" id='vol'}
                         <option value="{$vol.id}" {if condition="$vol.id eq $data.category2"}selected="selected"{/if}>{$vol.categoryname}</option>
                    {/volist}
                </select>
            </div>
            <div class="form-group col-md-7" >
                <label>APPID</label>
                <input type="text" id="appid" class="form-control" value="{$data.appid}" disabled>
            </div>
            <div class="form-group col-md-7" >
                <label>认证到期时间</label>
                <input type="text" class="form-control layui-input" value="{$data.endtime}" id="endtime">
            </div>
            <div class="form-group col-md-7" >
                <label>公司主体</label>
                <input type="text" id="company" class="form-control" disabled="disabled" value="{$data.company}">
            </div>
            <input type="hidden" id="tid" value="{$data.id}">
            <div class="form-group col-md-7" >
                <div id="btn_save" class="btn btn-info pull-right">保存</div>
            </div>
        </form>
    </div>
    <!-- /.box-body -->
    </section>
</div>
</body>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#endtime', //指定元素
            type: 'datetime'
        });
    });
    $(function(){
        $('#btn_save').click(function () {
            var _name = $('#name').val();
            var _id = $('#tid').val();
            var _category = $('#category').val();
            var _category2 = $('#category2').val();
            var _appid = $('#appid').val();
            var _endtime = $('#endtime').val();
            var _company = $('#company').val();
            var _password = $('#password').val();
            if(_name == ''){
                layerAlert('请输入账号昵称');
                return false;
            }
            if(_category == '' || _category2 == ''){
                layerAlert('请选择分类');
                return false;
            }
            if(_appid == ''){
                layerAlert('请输入appid');
                return false;
            }
            if(_endtime == ''){
                layerAlert('请输入认证到期时间');
                return false;
            }
            if(_company == ''){
                layerAlert('请输入公司主体');
                return false;
            }
            $.ajax({
                type: 'post',
                cache: false,
                url: '{:url("tencent/doEditTencent")}',
                data: {id:_id,name:_name,password:_password,category:_category,category2:_category2,appid:_appid,endtime:_endtime,company:_company},
                success: function(data) {
                    if(data.code=="0")
                    {
                        layerAlert('修改成功',function(){
                            parent.relist();
                            layerParentClose();
                        });
                    }else{
                        layerAlert('修改失败');
                    }
                }
            })
        })
    })
</script>
</html>